package com.ihg.hiex.admin.job;

import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.ihg.hiex.admin.service.session.ReportWritingService;

/**
 * 
 * @author dan
 *
 */
@Component("sessionTaskJob")
public class SessionReportJob {
    
    private static final Logger logger = LoggerFactory.getLogger(SessionReportJob.class);
    
    @Autowired
    private ReportWritingService reportWritingService;
    
    
    /**
     *  生成ppl, 经理， 学员报告
     */
    @Scheduled(cron = "0 0/5 * * * ?")
    public void generateReport() {
        
        logger.info("#generateReport() - Starting report Scheduler At " + new Date());
        
        try {
            reportWritingService.batchGeneratePplReport();
        } catch(Exception e) {
            logger.error("#generateReport() - Generate PPL report fail. {}", e);
        }
        
        try {
            reportWritingService.batchGenerateManagerReport();
        } catch(Exception e) {
            logger.error("#generateReport() - Generate Manager report fail. {}", e);
        }
        
        try {
            reportWritingService.batchGenerateDelegateReport();
        } catch(Exception e) {
            logger.error("#generateReport() - Generate Delegate report fail. {}", e);
        }
        
        logger.info("#generateReport() - Ending report Scheduler At " + new Date());
        
    }

}
